package ex10;

import java.util.Scanner;

class IllegalScoreException extends Exception {

	public IllegalScoreException(String string) {
		super(string);
	}
	
}

class IllegalNameException extends RuntimeException {

	public IllegalNameException(String string) {
		super(string);
	}
	
}

class Student {
	private String name;
	private int score;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		if (Character.isDigit(name.charAt(0))) {
			throw new IllegalNameException("the first char of name must not be digit, name=" + name);
		}
		this.name = name;
	}
	public int getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}
	public int addScore(int score) throws IllegalScoreException {
		if (score < 0 || score > 100) {
			throw new IllegalScoreException("score out of range, score=" + score);
		}
		this.score += score;
		return score;
	}
	@Override
	public String toString() {
		return "Student [name=" + name + ", score=" + score + "]";
	}
}



public class Test1 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while (true) {
			String string = scanner.nextLine();
			if (string.equals("new")) {
				String name = scanner.next();
				int score = scanner.nextInt();
				scanner.nextLine();
				Student student = new Student();
				try {
					student.setName(name);
					student.addScore(score);
				} catch (IllegalScoreException e) {
					System.out.println(e);
					continue;
				} catch (IllegalNameException e) {
					System.out.println(e);
					break;
				}
				System.out.println(student);
			} else {
				break;
			}
		}
		
		scanner.close();
		System.out.println("scanner closed");
		
		
		
	}
}